class ProjectConsumer
  require 'rubygems'
  require 'open-uri'
  require 'rexml/document'
  
  def initialize(host, user, password)
    @host = host
    @user = user
    @password = password
  end
  
  def get_projects
    url = @host + '/' + 'projects/' + @user
    response = open(url, :http_basic_authentication => [@user, @password])
    xml = response.read
    document = REXML::Document.new(xml)

    projects = Array.new
    REXML::XPath.each(document, '/ProjectIndex/ProjectRef') do |e|
      projects.push("#{e.attributes['Name']}")
    end
    return projects
  end
end